package com.myproject;

import java.util.concurrent.locks.LockSupport;

public class LockSupportTest {

    private volatile static boolean flag = true;

    public static void main(String[] args) throws InterruptedException {

        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (flag){}
                System.out.println("start");

                LockSupport.park(this);
                System.out.println(Thread.interrupted());
                System.out.println("end1");

                LockSupport.park(this);
                System.out.println(Thread.interrupted());
                System.out.println("end2");
            }
        });

        thread.start();
        Thread.sleep(3000);
        System.out.println("-----");
        LockSupport.unpark(thread);
        flag = false;

        Thread.sleep(3000);
        thread.interrupt();

        Thread.sleep(3000);
        System.out.println(thread.isInterrupted());

    }



}
